﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TuiXin
{
    public class BCD
    {
        public static string GetString(int code)
        {
            string s = "";
            string _code = code.ToString();
            for (int i = 0; i < _code.Length; i++)
            {
                s = s + chk(_code.Substring(i,1));
            } 
            return s;
        }
        private static string chk(string s)
        {
            switch (s)
            {
                case "0":
                    return "0000";
                    break;
                case "1":
                    return "0001";
                    break;
                case "2":
                    return "0010";
                    break;
                case "3":
                    return "0011";
                    break;
                case "4":
                    return "0100";
                    break;
                case "5":
                    return "0101";
                    break;
                case "6":
                    return "0110";
                    break;
                case "7":
                    return "0111";
                    break;
                case "8":
                    return "1000";
                    break;
                case "9":
                    return "1001";
                    break;
                default:
                    return "";


            }
        }
    }
}
